<template>
	<view class="orderExpress-contanier" v-show="isLoading">
		<view class="module" v-for="(v,i) in express" :key="i" @click="expressChange(v)">
			<view class="title">
				<view class="left-text">
					<unt-icon name="icon-daishouhuo" size="18" color="#000000" style="margin-left: auto;"></unt-icon>
					<text class="text text1">包裹{{i+1}}</text>
				</view>
				<view class="right-text">
					<text class="text text2">查看详情</text>
					<unt-icon name="icon-arrow" size="12" color="#999999" style="margin-left: auto;"></unt-icon>
				</view>
			</view>
			<view class="content">
				<unt-goods-detail :data="goodsArrange(v.logisticsGoods)" modal="order"></unt-goods-detail>
			</view>
		</view>
	</view>
</template>

<script>
	const Plugins = requirePlugin("logisticsPlugin");
	import * as Order from '@/api/order/index.js'
	export default {
		data() {
			return {
				isLoading:false,
				options:{},
				express:[]
			}
		},
		onLoad(options) {
			this.options = options;
			this.getPageData();
		},
		methods: {
			expressChange(v){
				Plugins.openWaybillTracking({
					waybillToken: v.waybillToken
				});
			},
			getPageData(){
				this.isLoading = false;
				const id = this.options.orderId;
				Order.logistics({
					orderId:id
				}).then(res => {
					this.express = res.data;
					if(res.data.length==1){
						this.expressChange(res.data[0])
					}
					this.isLoading = true;
				}).catch(err => err)
			}
		},
		computed:{
			goodsArrange(){
				return function(v){
					let data =v.map(r=>{
						return r.orderGoods;
					})
					return data;
				}
			}
		}
	}
</script>
<style>
	page {
		background: #F0F0F0;
	}
</style>
<style lang="scss" scoped>
	.orderExpress-contanier {
		position: relative;
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 0px 20rpx;
		padding-bottom: 60rpx;

		.module {
			width: 100%;
			background: #fff;
			padding: 20rpx;
			border-radius: 25rpx;
			margin-top: 30rpx;
			.title{
				display: flex;
				justify-content: space-between;
				border-bottom: 1px solid #f5f5f5;
				padding-bottom: 25rpx;
				margin-bottom: 15rpx;
				.text{
					font-size: 28rpx;
				}
				.text1{
					margin-left: 15rpx;
				}
				.text2{
					margin-right: 15rpx;
				}
			}
		}
	}
</style>